package com.xjm.viewservice.service;

import com.xjm.viewservice.entity.Product;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Panda
 * @create 2022-01-13 11:57
 */

@Service
public class ProductService {

    @Resource
    private RestTemplate restTemplate;

    @Resource
    private ProductServiceFeign productServiceFeign;

    /**
     * ribbon 方式，通过 RestTemplate
     * @return
     */
    public List<Product> listProducts(){
        return restTemplate.getForObject("http://DATA-SERVICE/products",List.class);

    }

    /**
     * feign 方式
     * @return
     */
    public List<Product> listProductsFeign(){
        return productServiceFeign.listProdcuts();

    }

}
